package com.learn.serviceloader

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import java.util.*

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        // 得到的是继承AbsPlugin的子类实例
        val list = ServiceLoader.load(AbsPlugin::class.java, javaClass.classLoader).toList();
        list.forEach {
            Log.e("onCreate: ", it.toString())
            it.init();
        }
    }
}